/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ihc.terminalbanco;

import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JFrame;
import ihc.terminalbanco.gui.events.Events;
import ihc.terminalbanco.gui.events.KeyActions;
import ihc.terminalbanco.gui.panels.BemVindoPane;
import ihc.terminalbanco.gui.panels.ConstructMenusPanelsMelhorIdade;
import javax.swing.JPanel;

/**
 * @author Rafael
 */
public class Main {

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String[] args) {
                ConstructMenusPanelsMelhorIdade.keyListener = new KeyActions();
                KeyActions keyActions = ConstructMenusPanelsMelhorIdade.keyListener;
                ConstructMenusPanelsMelhorIdade.actionListener = new Events(keyActions);
                
                Events events = ConstructMenusPanelsMelhorIdade.actionListener;
                ConstructMenusPanelsMelhorIdade.keyListener = new KeyActions();
		JFrame terminalFrame = new JFrame(
				"Terminal de Atendimento - Banco do Povo");
		terminalFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		terminalFrame.setResizable(true);
		Dimension dimensaoInicial = new Dimension(640, 480);
		terminalFrame.setMinimumSize(dimensaoInicial);
                terminalFrame.addKeyListener(keyActions);
		/*
		int rows = 4, cols = 4;
		GridLayout gridLayoutTerminal = new GridLayout(rows, cols, 20, 60);
		TerminalPane terminalPane = new TerminalPane("inicial", new Events(), new KeyActions(),
				gridLayoutTerminal);/*
									 * TerminalPane terminalPane = new
									 * TerminalPane("inicial", new Events(),
									 * null,springLayoutTerminal, rows, cols);
									 

		ArrayList<LabelButton> labelButtonList = new ArrayList<LabelButton>();

		labelButtonList.add(new LabelButton("Saldo", 1, 1));
		labelButtonList.add(new LabelButton("Saque", 1, 2));
		labelButtonList.add(new LabelButton("Extrato", 2, 1));
		labelButtonList.add(new LabelButton("A pagar", 2, 2));
		labelButtonList.add(new LabelButton("Cheque", 3, 1));
		labelButtonList.add(new LabelButton("Opções", 3, 2));
		labelButtonList.add(new LabelButton("Outros", 4, 1));
		labelButtonList.add(new LabelButton("Ajuda", 4, 2));

		 * labelButtonList.add(new LabelButton("1a", 1, 1));
		 * labelButtonList.add(new LabelButton("2a", 1, 2));
		 * labelButtonList.add(new LabelButton("3a", 2, 1));
		 * labelButtonList.add(new LabelButton("4a", 2, 2));
		 * labelButtonList.add(new LabelButton("5a", 3, 1));
		 * labelButtonList.add(new LabelButton("6a", 3, 2));
		 * labelButtonList.add(new LabelButton("7a", 4, 1));
		 * labelButtonList.add(new LabelButton("8a", 4, 2));
		 

		terminalPane.addLabelButtonList(labelButtonList);
		/*
		 * SpringUtilities.makeCompactGrid(terminalPane, //parent rows, cols, 3,
		 * 3, //initX, initY 3, 3); //xPad, yPad
		 */
    		//terminalPane.setVisible(true);
		//terminalFrame.add(ConstructMenusPanels.contructMainMenu());
                //terminalFrame.add(ConstructMenusPanels.contructExtratoMenu());
                //terminalFrame.add(ConstructMenusPanels.contructServicosMenu());
                //terminalFrame.add(ConstructMenusPanels.constructDemonstrativoMenu());
                //terminalFrame.add(ConstructMenusPanels.constructEmprestimoMenu());
                //terminalFrame.add(ConstructMenusPanels.constructPagamentoMenu());

                JPanel menuPrincipal = ConstructMenusPanelsMelhorIdade.constructMainMenu();
                events.setAtualPanel(menuPrincipal);
                events.setMenuPrincipalPanel(menuPrincipal);
                events.setFrameInterface(terminalFrame);
                keyActions.inicializaKeyAction(events);
                

                
                JPanel bemVindoPanel = new BemVindoPane(events, new Font(Font.SANS_SERIF,Font.PLAIN,30));
                terminalFrame.setContentPane(bemVindoPanel);
                terminalFrame.setVisible(true);
                
                //testes
//                JPanel testando = new TerminoComprovantePane(events, new Font(Font.SANS_SERIF,Font.PLAIN,30));
//                terminalFrame.setContentPane(testando);
//                terminalFrame.setVisible(true);
                
                //Delay de 3 segundos 
                //(deve ter outra maneira mas essa � a mais rapida que lembrei sem epsquisar hehe)
                long tempoInicial = System.currentTimeMillis();
                long tempoAtual = 0;
                while ((tempoAtual - tempoInicial) < 3000) {
                	tempoAtual = System.currentTimeMillis();
                }
                
                terminalFrame.setContentPane(menuPrincipal);
                terminalFrame.setVisible(true);
                
               

	}
}
